package com.zhihaoliang.moshi.biz.parser

import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import com.zhihaoliang.moshi.biz.models.Plant
import com.zhihaoliang.moshi.util.logJson

/**
 * @author 支豪亮
 * @date 2023/1/20 14:52
 * @des 格式化数据
 */

fun printPretty() {
    val plant = Plant(
        "coriandrum-sativum",
        "Cilantro",
        "Coriander",
        2,
        4,
        "A_scene_of_Coriander_leaves.JPG"
    )

    val moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build()
    val plantAdapter = moshi.adapter(Plant::class.java)

    logJson<Plant>(plant,plantAdapter)
}